//////////////////////////////////////////////////////////////////////
// Log.cpp: implementation of the Log class.
//////////////////////////////////////////////////////////////////////
 
#include "log.h"

//using namespace log4cplus;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
 
//Logger log::_logger = log4cplus::Logger::getInstance("main");

void Log(string msg, LOG_TYPE type)
{
	switch(type)
	{
		case L_NOTICE:
			//LOG4CPLUS_INFO(log::_logger, msg);
			cout << "INFO - " << msg << endl;
			break;
		case L_WARN: 
			//LOG4CPLUS_WARN(log::_logger, msg);
			cout << "WARN - " << msg << endl;
			break;
		case L_ERROR:
			//LOG4CPLUS_ERROR(log::_logger, msg);
			cout << "ERROR - " << msg << endl;
			break;
		case L_FATAL:
			//LOG4CPLUS_FATAL(log::_logger, msg);
			cout << "FATAL - " << msg << endl;
			break;
		default :
			//LOG4CPLUS_ERROR(log::_logger, "Log input wrong!");
			cout << "ERROR - " << "Log input wrong!" << endl;
	}
			
}

log& log::instance()
{
    static log log;
    return log;
}
 
bool log::load(string ctg)
{
    /* 
    if(!ctg.empty())
    {
		PropertyConfigurator::doConfigure(ctg);
	}
	else
	{
		int Log_level = INFO_LOG_LEVEL;
		
		SharedAppenderPtr _append_c(new ConsoleAppender());
		SharedAppenderPtr _append(new FileAppender(LOG4CPLUS_TEXT("log/test.log")));
		_append->setName(LOG4CPLUS_TEXT("Test"));

		std::string pattern = "[%d{%m/%d/%y %H:%M:%S}] [%p] - %m %n";
		std::auto_ptr<Layout> _layout(new PatternLayout(pattern));

		_append->setLayout(_layout);
				
		log::_logger.addAppender(_append);
		log::_logger.addAppender(_append_c);

		log::_logger.setLogLevel(Log_level);
	}
	*/ 
    return true;
}
